<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_JS数据类型</title>
</head>
<body>
<script>
    //JS数据类型 = 原始类型 + 引用类型
    //原始类型: number,string,boolean,undefined,null
    //引用类型: object,function,array,date....
    var a = 1;
    var b= 3.6;
    console.log(a,typeof a,b,typeof b);//整数小数都算number
    var c = "hello";
    var d= '你好呀~';
    console.log(c,typeof c,d,typeof d);//单引双引都算string
    var e = true;
    var f= false;
    console.log(e,typeof e,f,typeof f);//boolean
    var g ;
    console.log(g,typeof g);//undefined访问未赋值的变量推断不出来类型时就会得到"未定义型"
    //引用类型
    let obj = {};//定义空对象
    console.log(obj,typeof obj);//{}'object'
    let obj2={//定义带属性的对象
        name:"张三",
        age:18
    };
    console.log(obj2,typeof obj2);
    console.log(obj2.name,obj2.age);
    obj2.like = '放春节';//JS还可以后期动态的新增属性
    console.log(obj2,obj2.like);
    console.log(obj2.play);//访问不存在的属性时，得到的值是undefined

    //JS 数组
    let arr = ['周四',5,4.14,true];
    console.log(arr,typeof arr);
    console.log(arr[0],arr[1],arr[2],arr[3]);
    console.log(arr[99]);//访问数组不存在的下标时会得到undefined

    console.log(Boolean(0));
    console.log(Boolean(undefined));
    console.log(Boolean(null));
    console.log(Boolean(''));
    console.log(Boolean(""));
    console.log(Boolean(NaN));
    console.log("--------------------------")
    console.log(Boolean(1));
    console.log(Boolean(' '));
    console.log(Boolean(" "));
    console.log(Boolean('上午好!'));
    console.log(Boolean("山帅哥"));
    console.log("--------------------------")
    //Number()用于将参数转为数值类型，如果得不到数字结果，值为NaN(Not a Number)
    console.log(Number(true),typeof Number(true));
    console.log(Number(false),typeof Number(false));
    console.log(Number(3))
    console.log(Number('3'),typeof Number('3'))
    console.log(Number('哈哈哈'),typeof Number('哈哈哈'))



</script>


</body>
</html>